package cn.piesat.scanning.service.impl;

import cn.piesat.scanning.dao.HtFixedParameterDAO;
import cn.piesat.scanning.dto.HtFixedParameterDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 任务配置固定参数服务实现类
 */
@Service("htFixedParameterService")
public class HtFixedParameterServiceImpl implements cn.piesat.scanning.service.HtFixedParameterService {

    @Autowired
    private HtFixedParameterDAO htFixedParameterDAO;

    /**
     * 根据任务ID查询固定参数信息为map
     * @param taskId
     * @return
     */
    @Override
    public Map<String, Object> findByFixedtaskId(String taskId) {
        Map<String, Object> map = new HashMap<>();
        List<HtFixedParameterDTO> bytaskId = htFixedParameterDAO.findBytaskId(taskId);
        if(!bytaskId.isEmpty()){
            map = new HashMap<>();
            for (HtFixedParameterDTO dto: bytaskId) {
                map.put(dto.getParamKey(),dto.getParamVal());
            }
        }
        return map;
    }
    /**
     * 根据任务ID查询固定参数信息为map
     * @param taskId
     * @return
     */
    @Override
    public Map<String,Integer> findByFixedIndextaskId(String taskId) {
        Map<String,Integer> map = new HashMap<>();
        List<HtFixedParameterDTO> bytaskId = htFixedParameterDAO.findBytaskId(taskId);
        if(!bytaskId.isEmpty()){
            map = new HashMap<>();
            for (HtFixedParameterDTO dto: bytaskId) {
                map.put(dto.getParamKey(),dto.getSort());
            }
        }
        return map;
    }
}
